package io.renren.modules.basic.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.basic.entity.MtCcTaskRunInfoLogEntity;
import io.renren.modules.basic.service.MtCcTaskRunInfoLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-10-14 10:50:42
 */
@Api(description = "任务日志")
@RestController
@RequestMapping("generator/mtcctaskruninfolog")
public class MtCcTaskRunInfoLogController {
    @Autowired
    private MtCcTaskRunInfoLogService mtCcTaskRunInfoLogService;

    /**
     * 列表
     */
    @ApiOperation(value = "列表",notes="列表")
    @RequestMapping("/list")
    @RequiresPermissions("generator:mtcctaskruninfolog:list")
    public R list(@RequestParam Map<String, Object> params){
        /**
         * 条件：
         *      单号       task_code
         *      出入库     task_type
         *      操作人（出入口）     user_id
         *      开始时间    start_time
         *      结束时间    end_time
         */
        PageUtils page = mtCcTaskRunInfoLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation(value = "信息",notes="信息")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:mtcctaskruninfolog:info")
    public R info(@PathVariable("id") Integer id){
		MtCcTaskRunInfoLogEntity mtCcTaskRunInfoLog = mtCcTaskRunInfoLogService.getById(id);

        return R.ok().put("mtcctaskruninfolog", mtCcTaskRunInfoLog);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "保存",notes="保存")
    @RequestMapping("/save")
    @RequiresPermissions("generator:mtcctaskruninfolog:save")
    public R save(@RequestBody MtCcTaskRunInfoLogEntity mtCcTaskRunInfoLog){
		mtCcTaskRunInfoLogService.save(mtCcTaskRunInfoLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改",notes="修改")
    @RequestMapping("/update")
    @RequiresPermissions("generator:mtcctaskruninfolog:update")
    public R update(@RequestBody MtCcTaskRunInfoLogEntity mtCcTaskRunInfoLog){
		mtCcTaskRunInfoLogService.updateById(mtCcTaskRunInfoLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除",notes="删除")
    @RequestMapping("/delete")
    @RequiresPermissions("generator:mtcctaskruninfolog:delete")
    public R delete(@RequestBody Integer[] ids){
		mtCcTaskRunInfoLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
